/**
 * 
 */
package fhq.hcmute.qrcode.util;

/**
 * @author Hien Nguyen Le
 * @Email: nglehien@gmail.com
 */
public class QRCodeException extends Exception {
	private static final long serialVersionUID = 2466790568388306215L;
	public static final int INVALID_DEMENSION = 0x000000;
	public static final int INVALID_POINT = 0x000001;
	public static final int UNEQUAL_EXPONENT = 0x000010;
	public static final int QR_CODE_NOT_FOUND = 0x000011;
	public static final int INVALID_GALOIS_FILED_COFFEXPONENT = 0x000100;
	public static final int INVALID_REGION = 0x000101;
	public static final int INVALID_VERSION = 0x000101;
	public static final int SAMPLE_GRID_ERROR = 0x000110;
	public static final int ERROR_CORRECTION_CODEWORDS_FAILD = 0x000111;
	public static final int APPEND_QR_INFORMATION_FAILD = 0x001000;
	private String message;
	private int id;

	public QRCodeException(String message) {
		super();
		this.message = message;
	}

	public QRCodeException(int id) {
		super();
		this.id = id;
		if (this.id == QR_CODE_NOT_FOUND) {
			message = "Not found";
		} else if (this.id == SAMPLE_GRID_ERROR) {
			message = "Could not get sample";
		} else if (this.id == INVALID_VERSION) {
			message = "Could not determine version";
		} else if (this.id == INVALID_DEMENSION) {
			message = "Wrong demention";
		} else if (this.id == INVALID_POINT) {
			message = "Wrong point";
		} else if (this.id == UNEQUAL_EXPONENT) {
			message = " exponent unequal";
		} else if (this.id == ERROR_CORRECTION_CODEWORDS_FAILD) {
			message = "Could not create errror correction code words";
		}
	}

	@Override
	public String toString() {
		return "QRCodeException: " + message;
	}

	public int getId() {
		return id;
	}

}
